/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package projectcvip;

import filter.FilterStandard;
import filter.FilterSupervisor;
import filter.FilterWorker;

/**
 *
 * @author Michał
 */
public class Main
{

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
        System.out.println("CVIP - Start!");

        if (args.length == 0) //uruchomienie bez parametrow
        {
            JSBasic supervisor = new FilterSupervisor(3, 4, "img\\img3.png", "png");
            supervisor.start("jini://localhost");

            for (int i = 0; i < 4; i++)
            {
                JSBasic worker = new FilterWorker();
                worker.start("jini://localhost");
            }
        }
        else
        {
            String threadType = args[0];
            String host = args[1];
            if (threadType.equalsIgnoreCase("supervisor")) //uruchomienie jako supervisor
            {
                int maskSize = Integer.parseInt(args[2]);
                int noChannels = Integer.parseInt(args[3]);
                String inputPath = args[4];
                String formatName = args[5];
                JSBasic thread = new FilterSupervisor(maskSize, noChannels, inputPath, formatName);
                thread.start(host);
            }
            else if (threadType.equalsIgnoreCase("worker")) //uruchomienie jako worker
            {
                JSBasic thread = new FilterWorker();
                thread.start(host);
            }
            else if (threadType.equalsIgnoreCase("filter")) //uruchomienie jako zwykly filtr medianowy
            {
                int maskSize = Integer.parseInt(args[1]);
                String inputPath = args[2];
                String formatName = args[3];
                FilterStandard filterStandard = new FilterStandard(maskSize, inputPath, formatName);
                filterStandard.run();
            }

        }
        
    }
}
